package net.eearley.redpoint.app;

import java.util.List;

import net.eearley.redpoint.app.exception.ConsoleException;
import net.eearley.redpoint.app.utils.Util;

/**
 * The Class Validator.
 */
public class Validator {

	/**
	 * Check bet.
	 * 
	 * @param input
	 *            the input
	 * 
	 * @throws ConsoleException
	 *             the console exception
	 */
	public void checkBet(String input) throws ConsoleException {
		if (!Util.isInteger(input)) {
			throw new ConsoleException("Invalid Bet :" + input);
		}
	}

	/**
	 * Check horse.
	 * 
	 * @param val
	 *            the val
	 * @param list
	 *            the list
	 * 
	 * @throws ConsoleException
	 *             the console exception
	 */
	public void checkHorse(char val, List<Horse> list) throws ConsoleException {
		boolean isAHorse = ((Util.isInteger(val)) && (Integer.valueOf(val + "") > 0 && Integer
				.valueOf(val + "") < list.size()));
		if (!isAHorse)
			throw new ConsoleException("Invalid Horse Number:" + val);
	}

}
